package cz.tomasdvorak.cars.utils;

public class StringUtils {

    private StringUtils() {}

    public static String randomString(int min, int max) {
        int num = randomInt(min, max);
        byte b[] = new byte[num];
        for (int i = 0; i < num; i++) {
            b[i] = (byte) randomInt('a', 'z');
        }
        return new String(b);
    }

    private static int randomInt(int min, int max) {
        return (int) (Math.random() * (max - min) + min);
    }

    public static String join(Iterable<?> values, String delimiter) {
        StringBuilder buf = new StringBuilder();
        boolean first = true;
        for (Object o : values) {
            if (first) {
                first = false;
            } else {
                buf.append(delimiter);
            }
            buf.append(o);
        }
        return buf.toString();
    }
}
